/*----------------------------------------------------------------------------
 * CMSIS-RTOS 'main' function template
 *---------------------------------------------------------------------------*/
 
#include "RTE_Components.h"
#include  CMSIS_device_header
#include "cmsis_os2.h"
 
#ifdef RTE_Compiler_EventRecorder
#include "EventRecorder.h"
#endif

#include "rl_usb.h" 

void USBD_CDC0_NCM_Initialize (void);
void USBD_CDC0_NCM_Start (void);

///*----------------------------------------------------------------------------
// * Application main thread
// *---------------------------------------------------------------------------*/
//void app_main (void *argument) {
// 
//  // ...
//	
////	USBD_CDC0_NCM_Initialize();
////	USBD_CDC0_NCM_Start();
//	
//	USBD_Initialize    (0);               /* USB Device 0 Initialization        */
//  USBD_Connect       (0);               /* USB Device 0 Connect               */
//	
//	while (!USBD_Configured (0));
//	
//	osThreadSetPriority(osThreadGetId(), osPriorityIdle);
//  for (;;) {
////		 osDelay (1000);
//	}
//}
// 
//int main (void) {
// 
//  // System Initialization
//  SystemCoreClockUpdate();
//#ifdef RTE_Compiler_EventRecorder
//  // Initialize and start Event Recorder
//  EventRecorderInitialize(EventRecordError, 1U);
//#endif
//  // ...
// 
//  osKernelInitialize();                 // Initialize CMSIS-RTOS
//  osThreadNew(app_main, NULL, NULL);    // Create application main thread
//  osKernelStart();                      // Start thread execution
//  for (;;) {}
//}

/*
 * main: initialize and start the system
 */
int main (void) {
  osKernelInitialize ();                // initialize CMSIS-RTOS
 
  // initialize peripherals here
  USBD_Initialize   (0);                // USB Device 0 Initialization
  USBD_Connect      (0);                // USB Device 0 Connect
 
  // create 'thread' functions that start executing,
  // example: tid_name = osThreadCreate (osThread(name), NULL);
 
  osKernelStart ();                     // start thread execution 
  while (!USBD_Configured (0));
 
  osThreadSetPriority(osThreadGetId(), osPriorityIdle);
  for (;;);                             // Endless Loop
}
